import React, { Component } from 'react'

export default class Demo2 extends Component {
    state = {
        arr: [10, 20, 30]
    }
    render() {
        let { arr } = this.state
        return (
            <div>
                {arr.map((item, index) => {
                    return <span 
                    style={{ display: 'inline-block', width: 100, height: 100, background: 'pink', margin: 10 }}
                    key={index}
                    >{item}</span>
                })}
                <br />
                <button onClick={()=>{
                    arr.push((arr.length+1)*10)
                    this.setState({arr})
                }}>新增SPAN</button>
            </div>
        )
    }
}
